package com.tianhui.consignortwofei.mvp.ui.activity.hetong.activity.edit;

import android.text.TextUtils;
import android.view.View;

import com.tianhui.consignortwofei.R;
import com.tianhui.consignortwofei.mvp.model.hetong.ContractInfo;
import com.tianhui.consignortwofei.mvp.ui.activity.hetong.activity.ContractAddStepOneActivityNew;
import com.tianhui.consignortwofei.mvp.ui.activity.hetong.other.AdvancePaymentContract;
import com.tianhui.consignortwofei.mvp.ui.activity.hetong.other.CashDepositContract;
import com.tianhui.consignortwofei.mvp.ui.activity.hetong.other.DianJiaDepositContract;
import com.tianhui.consignortwofei.mvp.ui.activity.hetong.other.FuturesDepositContract;
import com.tianhui.consignortwofei.mvp.ui.activity.hetong.other.IContractType;
import com.tianhui.consignortwofei.mvp.ui.activity.hetong.other.IContractTypeView;
import com.tianhui.consignortwofei.mvp.ui.activity.hetong.other.NoCashDepositContract;
import com.tianhui.consignortwofei.mvp.ui.activity.hetong.other.ZhangQiDepositContract;
import com.tianhui.consignortwofei.mvp.ui.activity.hetong.other.view.AdvancePaymentView;
import com.tianhui.consignortwofei.mvp.ui.activity.hetong.other.view.CashDeliveryView;
import com.tianhui.consignortwofei.mvp.ui.activity.hetong.other.view.DianJiaDepositView;
import com.tianhui.consignortwofei.mvp.ui.activity.hetong.other.view.FuturesDepositView;
import com.tianhui.consignortwofei.mvp.ui.activity.hetong.other.view.NoCashDepositView;
import com.tianhui.consignortwofei.mvp.ui.activity.hetong.other.view.ZhangQiDepositView;


/**
 * @author fgs
 * @date 2021/5/20
 * @description
 **/
public class EditContractStepOneActivityNew extends ContractAddStepOneActivityNew {
    @Override
    public void initData() {


//        if (mContractInfo.methodtype.equals("1")) {
//            mSupplierDistributionLinearLayout.setVisibility(View.VISIBLE);
//            mDemanderPickLinearLayout.setVisibility(View.GONE);
//            mDeliveryPlaceClickItemView.setContent("供方配送");
//        } else {
//            mSupplierDistributionLinearLayout.setVisibility(View.GONE);
//            mDemanderPickLinearLayout.setVisibility(View.VISIBLE);
//            mDeliveryPlaceClickItemView.setContent("需方自提");
//            mDemanderPickInputItemView.setContent(mContractInfo.otherplacemethod);
//        }

        if (!TextUtils.isEmpty(mContractInfo.methodtype)) {
            mSupplierDistributionLinearLayout.setVisibility(View.VISIBLE);
            mDemanderPickLinearLayout.setVisibility(View.GONE);
            if (mContractInfo.methodtype.equals("1")) {
//                mSupplierDistributionLinearLayout.setVisibility(View.VISIBLE);
//                mDemanderPickLinearLayout.setVisibility(View.GONE);
                mDeliveryPlaceClickItemView.setContent("1、产品由需方自提");
            } else if (mContractInfo.methodtype.equals("2")){
//                mSupplierDistributionLinearLayout.setVisibility(View.GONE);
//                mDemanderPickLinearLayout.setVisibility(View.VISIBLE);
                mDeliveryPlaceClickItemView.setContent("2、甲方代办运输，运费由乙方承担，货物风险自甲方交付第一承运人起由乙方承担");
//                mDemanderPickInputItemView.setContent(mContractInfo.otherplacemethod);
            }else if (mContractInfo.methodtype.equals("3")){
                mDeliveryPlaceClickItemView.setContent("3、产品由甲方送货，运费由甲方承担");
            } else if (mContractInfo.methodtype.equals("4")){
                mDeliveryPlaceClickItemView.setContent("4、转货权");
            }else if (mContractInfo.methodtype.equals("5")){
                mDeliveryPlaceClickItemView.setContent("5、由甲方上游直发配送给乙方，具体送货时间以甲方上游送货时间为准，如与本合同约定送货时间不一致，不视为甲方逾期交货，甲方无需承担违约责任。");
            }
        }



        if (!TextUtils.isEmpty(mContractInfo.paytype)) {
            if ("1".equals(mContractInfo.paytype)){
                civ_jiesuan_type.setContent("现金");
            }else if ("3".equals(mContractInfo.paytype)){
                civ_jiesuan_type.setContent("银行承兑汇票");
            }else {
                civ_jiesuan_type.setContent("银行汇款");
            }

        }

        mSupplierDistributionClickItemView.setContent(mContractInfo.methoddate);

        mPackageStandardsClickItemView.setContent(mContractInfo.packagetype);

        mContractStandardTypeClickItemView.setContent(mContractInfo.qualitystandard);

        tv_search_bianhao.setVisibility(View.GONE);

        IContractTypeView iContractTypeView = null;

        if (mContractInfo.contracttype.equals(IContractType.ADVANCE_PAYMENT)) {
            mContractTypeClickItemView.setContent(getResources().getString(R.string.string_contract_type_advance));
            iContractTypeView = new AdvancePaymentView(getContext(), new AdvancePaymentContract());
//            mContractInfo.placemethod="汽车运输送至需方           。";
        } else if (mContractInfo.contracttype.equals(IContractType.CASH_DEPOSIT)) {
            mContractTypeClickItemView.setContent(getResources().getString(R.string.string_contract_type_cash));
            iContractTypeView = new CashDeliveryView(getContext(), new CashDepositContract());
        } else if (mContractInfo.contracttype.equals(IContractType.NO_CASH_DEPOSIT)) {
            mContractTypeClickItemView.setContent(getResources().getString(R.string.string_contract_type_no_cash));
            iContractTypeView = new NoCashDepositView(getContext(), new NoCashDepositContract());
        } else if (mContractInfo.contracttype.equals(IContractType.FUTURES_DEPOSIT)) {
            mContractTypeClickItemView.setContent(getResources().getString(R.string.string_contract_type_futures));
            iContractTypeView = new FuturesDepositView(getContext(), new FuturesDepositContract());
        }else if (mContractInfo.contracttype.equals(IContractType.ACCOUNTING_PERIOD)) {
            mContractTypeClickItemView.setContent(getResources().getString(R.string.string_contract_type_accounting));
            iContractTypeView = new ZhangQiDepositView(getContext(), new ZhangQiDepositContract());
        }else if (mContractInfo.contracttype.equals(IContractType.DIAN_JIA)) {
            mContractTypeClickItemView.setContent(getResources().getString(R.string.string_contract_type_dianjia));
            iContractTypeView = new DianJiaDepositView(getContext(), new DianJiaDepositContract());

        }

        if (iContractTypeView != null) {
            showContractTypeView(iContractTypeView);
            iContractTypeView.initViewData(mContractInfo);
        }
    }


    @Override
    public void initView() {

        setTitle("编辑合同");

        mLitigationClauseEditText.getEditText().setEnabled(false);
        mSupplierDistributionEditText.getEditText().setEnabled(false);

        mContractNumberInputItemView.setItemEnable(false);

        mSupplierDistributionEditText.setContentText(mContractInfo.placemethod);
        mLitigationClauseEditText.setContentText(mContractInfo.complain);
        mContractNumberInputItemView.setContent(mContractInfo.contractno);

    }

    @Override
    protected void openNextActivity(ContractInfo contractInfo) {
        openNextStepActivity(contractInfo, EditContractStepTwoActivity.class);
    }
}
